package com.lyw.db.dao

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.Query
import com.lyw.db.entites.Question
import kotlinx.coroutines.flow.Flow

@Dao
interface QuestionDao {
    @Insert
    suspend fun insertAll(vararg questions: Question)

    @Query("SELECT * FROM questions")
    suspend fun getAllQuestions(): List<Question>

    @Query("SELECT * FROM questions WHERE type = :type")
    suspend fun getQuestionsByType(type: Int): List<Question>

    @Query("SELECT * FROM questions WHERE type = :type AND knowledgeType = :knowledgeType")
    suspend fun getQuestionsByType(type: Int,knowledgeType:Int): List<Question>

    @Query("SELECT * FROM questions WHERE (type = :type OR type=:type2) AND knowledgeType = :knowledgeType")
    suspend fun getQuestionsByType(type: Int,type2:Int,knowledgeType:Int): List<Question>


    @Query("SELECT * FROM questions WHERE knowledgeType = :knowledgeType")
    suspend fun getQuestionsByKnowledgeType(knowledgeType:Int): List<Question>

    @Query("SELECT * FROM questions WHERE topType = :topType AND subType = :subType AND knowledgeType=:knowledgeType")
    suspend fun getQuestionsByType(topType: String,subType:String,knowledgeType: Int): List<Question>

//    @Query("SELECT * FROM questions WHERE knowledgeType = :knowledgeType AND knowledgeSubType=:knowledgeType")
//    suspend fun getQuestionsByType(knowledgeType:String,knowledgeSubType:String): List<Question>

    @Query("DELETE FROM questions")
    suspend fun deleteAll();
}